package vip.huhaiong.hlfood.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.huhaiong.hlfood.pojo.Rs;
import vip.huhaiong.hlfood.service.ListService;


@RestController
@RequestMapping("data")
public class ListController {
    ListService listService;
    @Autowired
    public ListController(ListService listService){
        this.listService = listService;
    }

    @GetMapping("/getIndexList")
    public Rs getIndexList() throws Exception {
        String url = "https://www.meishij.net/chufang/diy/?&page=1";
        return listService.getIndexData(url);
    }

    @GetMapping("/getDetailData")
    public Rs getDetailData(String url) throws Exception {
        return listService.getDetailData(url);
    }

    @GetMapping("/getSearchData")
    public Rs getSearchData(String keywords) throws Exception {
        return listService.getSearchData(keywords);
    }
    @GetMapping("/getDataByType")
    public Rs getDataByType(String type, String page) throws Exception {
        return listService.getDataByType(type, Integer.parseInt(page));
    }
    @GetMapping("/getVideoList")
    public Rs getVideoList(String page) throws Exception {
        return listService.getVideoList(Integer.parseInt(page));
    }
    @GetMapping("/getVideoData")
    public Rs getVideoData(String url) throws Exception {
        return listService.getVideoData(url);
    }
}
